@echo off
chcp 65001
echo ==========================================
echo 招聘系统微服务启动脚本 (Windows)
echo ==========================================

REM 检查Docker是否安装
docker --version >nul 2>&1
if errorlevel 1 (
    echo 错误: Docker未安装，请先安装Docker Desktop
    pause
    exit /b 1
)

REM 检查Docker Compose是否安装
docker-compose --version >nul 2>&1
if errorlevel 1 (
    echo 错误: Docker Compose未安装，请先安装Docker Compose
    pause
    exit /b 1
)

echo 1. 启动基础服务 (MySQL, RabbitMQ)...
docker-compose up -d

echo 等待服务启动...
timeout /t 30 /nobreak >nul

echo 2. 检查服务状态...
docker-compose ps

echo 3. 编译项目...
mvn clean compile -DskipTests

echo 4. 启动微服务...

REM 启动Eureka服务注册中心
echo 启动Eureka服务注册中心...
start "Eureka Server" cmd /k "cd recruitment-eureka && mvn spring-boot:run -Dspring-boot.run.jvmArguments=-Dserver.port=8761"

timeout /t 15 /nobreak >nul

REM 启动Spring Cloud Gateway服务
echo 启动Spring Cloud Gateway服务...
start "Spring Cloud Gateway" cmd /k "cd recruitment-zuul && mvn spring-boot:run -Dspring-boot.run.jvmArguments=-Dserver.port=8080"

timeout /t 10 /nobreak >nul

REM 启动认证服务
echo 启动认证服务...
start "Auth Service" cmd /k "cd recruitment-auth && mvn spring-boot:run -Dspring-boot.run.jvmArguments=-Dserver.port=8081"

timeout /t 10 /nobreak >nul

REM 启动求职者服务
echo 启动求职者服务...
start "Jobseeker Service" cmd /k "cd recruitment-jobseeker && mvn spring-boot:run -Dspring-boot.run.jvmArguments=-Dserver.port=8082"

timeout /t 10 /nobreak >nul

REM 启动企业服务
echo 启动企业服务...
start "Company Service" cmd /k "cd recruitment-company && mvn spring-boot:run -Dspring-boot.run.jvmArguments=-Dserver.port=8083"

timeout /t 10 /nobreak >nul

REM 启动简历服务
echo 启动简历服务...
start "Resume Service" cmd /k "cd recruitment-resume && mvn spring-boot:run -Dspring-boot.run.jvmArguments=-Dserver.port=8084"

timeout /t 10 /nobreak >nul

REM 启动招聘服务
echo 启动招聘服务...
start "Job Service" cmd /k "cd recruitment-job && mvn spring-boot:run -Dspring-boot.run.jvmArguments=-Dserver.port=8085"

timeout /t 10 /nobreak >nul

REM 启动统计服务
echo 启动统计服务...
start "Statistics Service" cmd /k "cd recruitment-statistics && mvn spring-boot:run -Dspring-boot.run.jvmArguments=-Dserver.port=8086"

echo ==========================================
echo 所有服务启动完成！
echo ==========================================
echo 服务访问地址:
echo 网关地址: http://localhost:8080
echo Eureka控制台: http://localhost:8761
echo RabbitMQ管理界面: http://localhost:15672
echo 用户名/密码: guest/guest
echo ==========================================
echo 按任意键退出...
echo ==========================================

pause 